package com.ropeok.service.impl;

import com.ropeok.dao.RoleDao;
import com.ropeok.entity.Role;
import com.ropeok.service.RolePrivilegeService;
import com.ropeok.service.RoleService;
import org.mybatis.logging.Logger;
import org.mybatis.logging.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @BelongsProject: task2
 * @BelongsPackage: com.ropeok.service
 * @Author: zhofeifan
 * @CreateTime: 2022-08-23  14:44
 * @Description: TODO
 * @Version: 1.0
 */
@Service("roleService")
public class RoleServiceImpl implements RoleService {
    private static Logger logger= LoggerFactory.getLogger(RoleService.class);
    @Autowired
    private RoleDao roleDao;
    /**
     * @description: 根据ID查询角色记录
     * @author: zhoufeifan
     * @date: 2022/9/15 10:28
     * @param: [long]
     * @return: com.ropeok.entity.Role
    **/

    @Override
    public Role findRoleById(long id) {
       Role role =  roleDao.findRoleById(id);
       return  role;
    }
    /**
     * @description: 查询角色列表
     * @author: zhoufeifan
     * @date: 2022/9/15 10:29
     * @param: []
     * @return: java.util.List<com.ropeok.entity.Role>
    **/
    @Override
    public List<Role> getRoleList() {
        return roleDao.getRoleList();
    }
    /**
     * @description: 增加角色记录
     * @author: zhoufeifan
     * @date: 2022/9/15 10:29
     * @param: [com.ropeok.entity.Role]
     * @return: int
    **/

    @Override
    @Transactional(rollbackFor = Throwable.class)
    public int addRole(Role role) {
        return roleDao.addRole(role);
    }
    /**
     * @description: 删除角色记录
     * @author: zhoufeifan
     * @date: 2022/9/15 10:29
     * @param: [long]
     * @return: int
    **/

    @Override
    @Transactional(rollbackFor = Throwable.class)
    public int deleteRole(long id) {
        int i = roleDao.deleteRole(id);
        return i;
    }
    /**
     * @description: 更新角色记录
     * @author: zhoufeifan
     * @date: 2022/9/15 10:30
     * @param: [com.ropeok.entity.Role]
     * @return: int
    **/
    @Override
    @Transactional(rollbackFor = Throwable.class)
    public int updateRole(Role role) {
        return roleDao.updateRole(role);
    }

}
